#!/usr/bin/env python
#coding:utf-8

import wx

class SheetPanel ( wx.Panel ):
    
    def __init__( self, parent ):
        wx.Panel.__init__ ( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.Size( -1,-1 ), style = wx.TAB_TRAVERSAL )
        
        bSizer3 = wx.BoxSizer( wx.VERTICAL )
        
        self.m_bitmap2 = wx.StaticBitmap( self, wx.ID_ANY, wx.Bitmap( u"images/sheet.png", wx.BITMAP_TYPE_ANY ), wx.DefaultPosition, wx.DefaultSize, 0 )
        bSizer3.Add( self.m_bitmap2, 0, wx.ALL, 5 )
        
        font1 = wx.Font( 13, 70, 93, 92, False, wx.EmptyString )
        font2 = wx.Font( wx.NORMAL_FONT.GetPointSize(), 70, 93, 90, False, wx.EmptyString )
        
        self.LConsTolerInfo = wx.StaticText(self, label = u'前束偏差：', pos = wx.Point(0, 0))
        self.LConsTolerInfo.SetForegroundColour(wx.Colour(0, 128, 0))
        self.LCambTolerInfo = wx.StaticText(self, label = u'外倾偏差：', pos = wx.Point(0, 20))
        self.LCambTolerInfo.SetForegroundColour(wx.Colour(0, 128, 0))
        
        self.RConsTolerInfo = wx.StaticText(self, label = u'前束偏差：', pos = wx.Point(700, 0))
        self.RConsTolerInfo.SetForegroundColour(wx.Colour(0, 128, 0))
        self.RCambTolerInfo = wx.StaticText(self, label = u'外倾偏差：', pos = wx.Point(700, 20))
        self.RCambTolerInfo.SetForegroundColour(wx.Colour(0, 128, 0))
        
        self.LCamberAngle = wx.StaticText(self, label = u'前束角：0.000', pos = wx.Point(6, 210))
        self.LCamberAngle.SetForegroundColour(wx.RED)
        self.LCamberAngle.SetFont(font1)
        self.LConstraintAngle = wx.StaticText(self, label = u'外倾角：0.000', pos = wx.Point(6,230))
        self.LConstraintAngle.SetForegroundColour(wx.RED)
        self.LConstraintAngle.SetFont(font1)
        self.LZeroPlanePV1 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(312,13))
        self.LZeroPlanePV1.SetFont(font2)
        self.LZeroPlanePV2 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(321,138))
        self.LZeroPlanePV2.SetFont(font2)
        self.LZeroPlanePV3 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(315,203))
        self.LZeroPlanePV3.SetFont(font2)
        self.LPartPlanePV1 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(150,29))
        self.LPartPlanePV1.SetFont(font2)
        self.LPartPlanePV2 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(143,135))
        self.LPartPlanePV2.SetFont(font2)
        self.LPartPlanePV3 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(144,180))
        self.LPartPlanePV3.SetFont(font2)
        self.LRealPV1 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(9,38))
        self.LRealPV1.SetForegroundColour(wx.BLUE)
        self.LRealPV1.SetFont(font2)
        self.LRealPV2 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(9,97))
        self.LRealPV2.SetForegroundColour(wx.BLUE)
        self.LRealPV2.SetFont(font2)
        self.LRealPV3 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(9,166))
        self.LRealPV3.SetForegroundColour(wx.BLUE)
        self.LRealPV3.SetFont(font2)
        
        self.RCamberAngle = wx.StaticText(self, label = u'前束角：0.000', pos = wx.Point(723, 210))
        self.RCamberAngle.SetForegroundColour(wx.RED)
        self.RCamberAngle.SetFont(font1)
        self.RConstraintAngle = wx.StaticText(self, label = u'外倾角：0.000', pos = wx.Point(723,230))
        self.RConstraintAngle.SetForegroundColour(wx.RED)
        self.RConstraintAngle.SetFont(font1)
        self.RZeroPlanePV1 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(503,13))
        self.RZeroPlanePV1.SetFont(font2)
        self.RZeroPlanePV2 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(496,138))
        self.RZeroPlanePV2.SetFont(font2)
        self.RZeroPlanePV3 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(502,203))
        self.RZeroPlanePV3.SetFont(font2)
        self.RPartPlanePV1 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(660,29))
        self.RPartPlanePV1.SetFont(font2)
        self.RPartPlanePV2 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(660,135))
        self.RPartPlanePV2.SetFont(font2)
        self.RPartPlanePV3 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(665,180))
        self.RPartPlanePV3.SetFont(font2)
        self.RRealPV1 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(805,38))
        self.RRealPV1.SetForegroundColour(wx.BLUE)
        self.RRealPV1.SetFont(font2)
        self.RRealPV2 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(810,97))
        self.RRealPV2.SetForegroundColour(wx.BLUE)
        self.RRealPV2.SetFont(font2)
        self.RRealPV3 = wx.StaticText(self, label = '0.000mm', pos = wx.Point(809,166))
        self.RRealPV3.SetForegroundColour(wx.BLUE)
        self.RRealPV3.SetFont(font2)
        
        self.SetSizer( bSizer3 )
        self.Layout()
        bSizer3.Fit( self )
        
    def SetLeftRealPV(self, pv1, pv2, pv3):
        self.LRealPV1.SetLabel('%.3fmm' % pv1)
        self.LRealPV2.SetLabel('%.3fmm' % pv2)
        self.LRealPV3.SetLabel('%.3fmm' % pv3)
        
    def SetRightRealPV(self, pv4, pv5, pv6):
        self.RRealPV1.SetLabel('%.3fmm' % pv4)
        self.RRealPV2.SetLabel('%.3fmm' % pv5)
        self.RRealPV3.SetLabel('%.3fmm' % pv6)
        
    def SetLeftZeroPV(self, pv1, pv2, pv3):
        self.LZeroPlanePV1.SetLabel('%.3fmm' % pv1)
        self.LZeroPlanePV2.SetLabel('%.3fmm' % pv2)
        self.LZeroPlanePV3.SetLabel('%.3fmm' % pv3)
        
    def SetRightZeroPV(self, pv4, pv5, pv6):
        self.RZeroPlanePV1.SetLabel('%.3fmm' % pv4)
        self.RZeroPlanePV2.SetLabel('%.3fmm' % pv5)
        self.RZeroPlanePV3.SetLabel('%.3fmm' % pv6)
        
    def SetLeftPartPV(self, pv1, pv2, pv3):
        self.LPartPlanePV1.SetLabel('%.3fmm' % pv1)
        self.LPartPlanePV2.SetLabel('%.3fmm' % pv2)
        self.LPartPlanePV3.SetLabel('%.3fmm' % pv3)
        
    def SetRightPartPV(self, pv4, pv5, pv6):
        self.RPartPlanePV1.SetLabel('%.3fmm' % pv4)
        self.RPartPlanePV2.SetLabel('%.3fmm' % pv5)
        self.RPartPlanePV3.SetLabel('%.3fmm' % pv6)
        
    def SetLeftConsTolerInfo(self, angle, toler):
        if not angle and not toler:
            info = u"前束角：-----~-----"
        else:
            info = u'前束角：%.3f~%.3f' % (angle, toler)
        self.LConsTolerInfo.SetLabel(info)
    
    def SetLeftCambTolerInfo(self, angle, toler):
        if not angle and not toler:
            info = u"外倾角：-----~-----"
        else:
            info = u'外倾角：%.3f~%.3f' % (angle, toler)
        self.LCambTolerInfo.SetLabel(info)
    
    def SetRightConsTolerInfo(self, angle, toler):
        if not angle and not toler:
            info = u"前束角：-----~-----"
        else:
            info = u'前束角：%.3f~%.3f' % (angle, toler)
        self.RConsTolerInfo.SetLabel(info)    
        
    def SetRightCambTolerInfo(self, angle, toler):
        if not angle and not toler:
            info = u"外倾角：-----~-----"
        else:
            info = u'外倾角：%.3f~%.3f' % (angle, toler)
        self.RCambTolerInfo.SetLabel(info)
        
    def SetLeftResult(self, consangle, consresult, cambangle, cambresult):
        self.LCamberAngle.SetLabel(u'外倾角：%.3f' % cambangle)
        if cambresult:
            self.LCamberAngle.SetForegroundColour(wx.GREEN)
        else:
            self.LCamberAngle.SetForegroundColour(wx.RED)
        
        self.LConstraintAngle.SetLabel(u'前束角：%.3f' % consangle)
        if consresult:
            self.LConstraintAngle.SetForegroundColour(wx.GREEN)
        else:
            self.LConstraintAngle.SetForegroundColour(wx.RED)
            
    def SetRightResult(self, consangle, consresult, cambangle, cambresult):
        self.RCamberAngle.SetLabel(u'外倾角：%.3f' % cambangle)
        if cambresult:
            self.RCamberAngle.SetForegroundColour(wx.GREEN)
        else:
            self.RCamberAngle.SetForegroundColour(wx.RED)
        
        self.RConstraintAngle.SetLabel(u'前束角：%.3f' % consangle)
        if consresult:
            self.RConstraintAngle.SetForegroundColour(wx.GREEN)
        else:
            self.RConstraintAngle.SetForegroundColour(wx.RED)
            